package com.lc202401;

/**
 * Description:
 *
 * @Create 2024/1/3 23:14
 * @Version 1.0
 */
public class Solution2239 {
    public int findClosestNumber(int[] nums) {
        int res = Integer.MAX_VALUE;
        for (int num : nums) {
            if (Math.abs(res) > Math.abs(num)) {
                res = num;
                continue;
            }
            if (Math.abs(res) == Math.abs(num)) {
                res = Math.max(res, num);
            }
        }
        return res;
    }
}
